home *** CD-ROM | disk | FTP | other *** search
/ Chip 1996 November / CHIP Kasım 1996.iso / prog / tw / tfw.5 / WCONFIG.SLT < prev    next >
Text File  |  1994-12-07  |  5KB  |  195 lines

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. //   W C O N F I G . S L T
  4. //
  5. //   Copyright (C) 1988,1989,1990,1991 Exis Inc.
  6. //   Copyright (C) 1994 deltaComm Development, Inc.
  7. //
  8. //   - Written by Colin Sampaleanu.
  9. //   - Modifications by Jeff Woods, Feb '91, to add help function and support
  10. //     for locked modems.
  11. //   - Modifications for Telix for Windows July '94
  12. //
  13. //   This is a Host Mode configuration script for Telix for Windows.
  14. //   It reads from and saves parameters to the file WINHOST.CNF.
  15. //
  16. //////////////////////////////////////////////////////////////////////////////
  17.  
  18. str modem_lock[5] = "0",
  19.     host_downloads[64],
  20.     host_uploads[64],
  21.     our_dir[64];
  22. int direct_connect = 0,
  23.     closed_sys = 0,
  24.     temp_var;
  25.  
  26. #INCLUDE "WHUTILS.SLT"
  27.  
  28. //////////////////////////////////////////////////////////////////////////////
  29.  
  30. main() {
  31.  
  32.   get_our_dir();
  33.   read_host_config_file();
  34.   host_configure();
  35.  
  36. }
  37.  
  38.  
  39. //////////////////////////////////////////////////////////////////////////////
  40.  
  41. host_configure() {
  42.  
  43.   str s[200];
  44.   int c, f, i, stat;
  45.  
  46.   if (!host_downloads) {
  47.     if (getenv ("HOST2DIR", s) != 0) {
  48.       host_downloads = our_dir;
  49.       strcat (host_downloads, "XFER\");
  50.     }
  51.     else {
  52.       host_downloads = _telix_dir;
  53.       strcat(host_downloads, "HOSTDOWN\");
  54.     }
  55.   }
  56.  
  57.   if (!host_uploads) {
  58.     if (getenv ("HOST2DIR", s) != 0) {
  59.       host_uploads = our_dir;
  60.       strcat (host_uploads, "XFER\");
  61.     }
  62.     else {
  63.       host_uploads = _telix_dir;
  64.       strcat(host_uploads, "HOSTDOWN\");
  65.     }
  66.   }
  67.  
  68.   while (1) {
  69.     clear_scr ();
  70.     prints("^M^JWCONFIG - WinHost Mode Configuration Script^M^J");
  71.     printsc("A: Host download directory: ");
  72.     prints(host_downloads);
  73.     printsc("B: Host upload directory  : ");
  74.     prints(host_uploads);
  75.     printsc("C: Connection type        : ");
  76.     if (direct_connect)
  77.       prints("Direct");
  78.     else
  79.       prints("Modem");
  80.     printsc("D: Lock Speed (0=none)    : ");
  81.     prints(modem_lock);
  82.     printsc("E: Sign-up mode           : ");
  83.     if (closed_sys) {
  84.       prints ("Closed (users may not sign up on-line)");
  85.     }
  86.     else {
  87.       prints ("Open   (users may sign up on-line)");
  88.     }
  89.  
  90.     prints("^M^JF: Exit without saving changes.");
  91.     prints("G: Exit and save changes to disk.^M^J");
  92.  
  93.     printsc("Which option? ");
  94.     gets(s, 1);
  95.     prints("");
  96.     c = toupper(subchr(s, 0));
  97.  
  98.     if (c < 'A' || c > 'G')
  99.       continue;
  100.  
  101.     if (c >= 'A' && c <= 'D')
  102.       printsc("Enter new value (Esc to abort): ");
  103.  
  104.     if (c == 'A') {
  105.       s = host_downloads;
  106.       stat = inputbox ("Host Download Directory", "Directory:", s);
  107.       if (stat == 1) {
  108.         host_downloads = s;
  109.         strupper(host_downloads);
  110.       }
  111.       if ((i = strlen(host_downloads)) != 0)       // add slash if needed
  112.         if (subchr(host_downloads, i - 1) != '\')
  113.           copystr("\", host_downloads, i, 1);
  114.     }
  115.  
  116.     else if (c == 'B') {
  117.       s = host_uploads;
  118.       stat = inputbox ("Host Upload Directory", "Directory:", s);
  119.       if (stat == 1) {
  120.         host_uploads = s;
  121.         strupper(host_uploads);
  122.       }
  123.       if ((i = strlen(host_uploads)) != 0)
  124.         if (subchr(host_uploads, i - 1) != '\')
  125.         copystr("\", host_uploads, i, 1);
  126.     }
  127.  
  128.     else if (c == 'C') {
  129.       direct_connect = ! direct_connect;
  130.     }
  131.  
  132.     else if (c == 'D') {
  133.       stat = gets(s, 5);
  134.       if (stat != -1) {
  135.         temp_var = stoi(s);
  136.         itos(temp_var, modem_lock);
  137.       }
  138.     }
  139.  
  140.     else if (c == 'E') {
  141.       closed_sys = ! closed_sys;
  142.     }
  143.  
  144.     else if (c == 'F') {
  145.       prints("^M^JWCONFIG done.^M^J");
  146.       return;
  147.     }
  148.  
  149.     else if (c == 'G') {
  150.  
  151.       if (! check_directory (host_downloads)) {
  152.         s = host_downloads;
  153.         strcat (s, " does not exist^M^JHost will not run intil its directories exist");
  154.         msgbox ("Warning", s, 0);
  155.       }
  156.  
  157.       if ((strcmpi (host_downloads, host_uploads) != 0) && (! check_directory (host_uploads))) {
  158.         s = host_uploads;
  159.         strcat (s, " does not exist^M^JHost will not run intil its directories exist");
  160.         msgbox ("Warning", s, 0);
  161.       }
  162.  
  163.       s = our_dir;
  164.       strcat(s, "WINHOST.CNF");
  165.       f = fopen(s, "w");
  166.  
  167.       if (!f) {
  168.         printsc("Error writing to ");
  169.         printsc(s);
  170.         prints("!");
  171.         continue;
  172.       }
  173.  
  174.       fputs(host_downloads, f);
  175.       fputs("^M^J", f);
  176.       fputs(host_uploads, f);
  177.       fputs("^M^J", f);
  178.       if (direct_connect)
  179.         fputs("Direct^M^J", f);
  180.       else
  181.         fputs("Modem^M^J", f);
  182.       fputs(modem_lock, f);
  183.       fputs("^M^J", f);
  184.       if (closed_sys)
  185.         fputs ("Closed", f);
  186.       else
  187.         fputs ("Open", f);
  188.  
  189.       prints("^M^JWCONFIG done.^M^J");
  190.       fclose(f);
  191.       return;
  192.     }
  193.   }
  194. }
  195.